/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.  All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto.  Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/

#pragma once

#if __linux__
#include <stddef.h>
#endif

#ifdef RTXGI_EXPORT_DLL
    #ifdef _MSC_VER
        #define RTXGI_API __declspec(dllexport)
    #elif __GNUC__
        #define RTXGI_API __attribute__((visibility("default")))
    #endif
#else
    #define RTXGI_API 
#endif

namespace rtxgi
{
    struct RTXGI_VERSION
    {
        static const int major = 1;
        static const int minor = 3;
        static const int revision = 7;

        inline static const char* getVersionString()
        {
            return "1.3.7";
        }
    };

    struct ShaderBytecode
    {
        const void* pData = nullptr;
        size_t size = 0;
    };

    #define RTXGI_SAFE_RELEASE(x) { if(x) { x->Release(); x = NULL; } }
    #define RTXGI_SAFE_DELETE(x) { if(x) delete x; x = NULL; }
    #define RTXGI_SAFE_DELETE_ARRAY(x) { if(x) delete[] x; x = NULL; }
    #define RTXGI_ALIGN(_alignment, _val) (((_val + _alignment - 1) / _alignment) * _alignment)

    /**
     * ERTXGIStatus
     * An enumeration for SDK status return codes.
     */
    enum ERTXGIStatus
    {
        OK = 0,
        ERROR_DDGI_INVALID_PROBE_COUNTS,
        ERROR_DDGI_INVALID_RESOURCE_INDICES_BUFFER,
        ERROR_DDGI_INVALID_RESOURCE_INDICES_UPLOAD_BUFFER,
        ERROR_DDGI_INVALID_CONSTANTS_BUFFER,
        ERROR_DDGI_INVALID_CONSTANTS_UPLOAD_BUFFER,
        ERROR_DDGI_INVALID_RESOURCES_DESC,
        ERROR_DDGI_MAP_FAILURE_RESOURCE_INDICES_UPLOAD_BUFFER,
        ERROR_DDGI_MAP_FAILURE_CONSTANTS_UPLOAD_BUFFER,
        ERROR_DDGI_MAP_FAILURE_VARIABILITY_READBACK_BUFFER,

        ERROR_DDGI_D3D12_INVALID_RESOURCE_DESCRIPTOR_HEAP,

        ERROR_DDGI_VK_INVALID_RESOURCE_INDICES_UPLOAD_MEMORY,
        ERROR_DDGI_VK_INVALID_CONSTANTS_UPLOAD_MEMORY,

        // --- DDGI Status Codes -----------------------------------------

        // Managed Resources Mode (SDK manages volume resources)
        ERROR_DDGI_INVALID_BYTECODE_PROBE_BLENDING_IRRADIANCE,
        ERROR_DDGI_INVALID_BYTECODE_PROBE_BLENDING_DISTANCE,
        ERROR_DDGI_INVALID_BYTECODE_PROBE_RELOCATION,
        ERROR_DDGI_INVALID_BYTECODE_PROBE_RELOCATION_RESET,
        ERROR_DDGI_INVALID_BYTECODE_PROBE_CLASSIFICATION,
        ERROR_DDGI_INVALID_BYTECODE_PROBE_CLASSIFICATION_RESET,
        ERROR_DDGI_INVALID_BYTECODE_PROBE_VARIABILITY_REDUCTION,
        ERROR_DDGI_INVALID_BYTECODE_PROBE_VARIABILITY_EXTRA_REDUCTION,

        ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_RAY_DATA,
        ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_IRRADIANCE,
        ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_DISTANCE,
        ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_DATA,
        ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_VARIABILITY,
        ERROR_DDGI_ALLOCATE_FAILURE_TEXTURE_PROBE_VARIABILITY_AVERAGE,

        ERROR_DDGI_D3D12_INVALID_DEVICE,
        ERROR_DDGI_D3D12_CREATE_FAILURE_PSO,
        ERROR_DDGI_D3D12_CREATE_FAILURE_ROOT_SIGNATURE,
        ERROR_DDGI_D3D12_CREATE_FAILURE_DESCRIPTORS,

        ERROR_DDGI_VK_INVALID_DEVICE,
        ERROR_DDGI_VK_INVALID_PHYSICAL_DEVICE,
        ERROR_DDGI_VK_INVALID_DESCRIPTOR_POOL,
        ERROR_DDGI_VK_CREATE_FAILURE_LAYOUTS,
        ERROR_DDGI_VK_CREATE_FAILURE_PIPELINE,
        ERROR_DDGI_VK_CREATE_FAILURE_DESCRIPTOR_SET,

        // Unmanaged Resource Mode (Application manages volume resources)
        ERROR_DDGI_INVALID_TEXTURE_PROBE_RAY_DATA,
        ERROR_DDGI_INVALID_TEXTURE_PROBE_IRRADIANCE,
        ERROR_DDGI_INVALID_TEXTURE_PROBE_DISTANCE,
        ERROR_DDGI_INVALID_TEXTURE_PROBE_DATA,
        ERROR_DDGI_INVALID_TEXTURE_PROBE_VARIABILITY,
        ERROR_DDGI_INVALID_TEXTURE_PROBE_VARIABILITY_AVERAGE,
        ERROR_DDGI_INVALID_TEXTURE_PROBE_VARIABILITY_READBACK,

        ERROR_DDGI_D3D12_INVALID_ROOT_SIGNATURE,
        ERROR_DDGI_D3D12_INVALID_DESCRIPTOR,
        ERROR_DDGI_D3D12_INVALID_PSO_PROBE_BLENDING_IRRADIANCE,
        ERROR_DDGI_D3D12_INVALID_PSO_PROBE_BLENDING_DISTANCE,
        ERROR_DDGI_D3D12_INVALID_PSO_PROBE_RELOCATION,
        ERROR_DDGI_D3D12_INVALID_PSO_PROBE_RELOCATION_RESET,
        ERROR_DDGI_D3D12_INVALID_PSO_PROBE_CLASSIFICATION,
        ERROR_DDGI_D3D12_INVALID_PSO_PROBE_CLASSIFICATION_RESET,
        ERROR_DDGI_D3D12_INVALID_PSO_PROBE_REDUCTION,
        ERROR_DDGI_D3D12_INVALID_PSO_PROBE_EXTRA_REDUCTION,

        ERROR_DDGI_VK_INVALID_DESCRIPTOR_SET,
        ERROR_DDGI_VK_INVALID_PIPELINE_LAYOUT,
        ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_RAY_DATA,
        ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_IRRADIANCE,
        ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_DISTANCE,
        ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_DATA,
        ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_VARIABILITY,
        ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_VARIABILITY_AVERAGE,
        ERROR_DDGI_VK_INVALID_IMAGE_MEMORY_PROBE_VARIABILITY_READBACK,
        ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_RAY_DATA,
        ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_IRRADIANCE,
        ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_DISTANCE,
        ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_DATA,
        ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_VARIABILITY,
        ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_VARIABILITY_AVERAGE,
        ERROR_DDGI_VK_INVALID_IMAGE_VIEW_PROBE_VARIABILITY_READBACK,
        ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_BLENDING_IRRADIANCE,
        ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_BLENDING_DISTANCE,
        ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_RELOCATION,
        ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_RELOCATION_RESET,
        ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_CLASSIFICATION,
        ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_CLASSIFICATION_RESET,
        ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_VARIABILITY_REDUCTION,
        ERROR_DDGI_VK_INVALID_SHADER_MODULE_PROBE_VARIABILITY_EXTRA_REDUCTION,
        ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_BLENDING_IRRADIANCE,
        ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_BLENDING_DISTANCE,
        ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_RELOCATION,
        ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_RELOCATION_RESET,
        ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_CLASSIFICATION,
        ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_CLASSIFICATION_RESET,
        ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_VARIABILITY_REDUCTION,
        ERROR_DDGI_VK_INVALID_PIPELINE_PROBE_VARIABILITY_EXTRA_REDUCTION,

        // ---------------------------------------------------------------
    };

}
